import axios from 'axios';
import _ from 'lodash';
let LocationHostName = window.location.hostname;
if (process.env.NODE_ENV === 'development') {
    LocationHostName = '/api';
}else{
    LocationHostName=window.location.origin;
}
let API = {
    ASSET_SERVER_URL:LocationHostName,
    SCAN_IS_OPEN: '/api/v1/vbar/open', //查询扫码器是否开着
    SCAN_CLOSE: '/api/v1/vbar/close', //关闭扫码器
    SCAN_SCAN: '/api/v1/vbar/scan', //扫码读取
    GET_USERINFO: '/api/v1/order/grxx', //扫码读取
    GET_HISTORY: '/api/v1/order/history/actions/list', //查询已缴费账单
    GET_PENDING_ORDER: '/api/v1/order/actions/list', //查询待缴费账单
    GET_PAY: '/api/v1/order/actions/pay', //支付账单
    GET_COUNT: '/api/v1/order/actions/amount/cal', //支付前试算
    GET_PAY_CS: '/api/v1/order/demo/actions/pay', //支付测试
    GET_CANCEL_PAY: '/api/v1/order/actions/cancel', //支付取消
    GET_PORT: '/api/v1/serial/port/actions/list', //查询串口端口列表
    GET_PLAYOK_DETAIL: '/api/v1/order/history/detail/actions/list', //查询已缴费账单明细
    GET_DRUGS: '/api/v1/order/wj/actions/list', //药品价格查询
    GET_USERINFO: '/api/v1/order/grxx', //药品价格查询
    
};

export function getConfig(){
    return new Promise(resolve=>{
        axios.get(`${window.location.origin}/webconfig.json?v=${new Date().getTime()}`).then((response) => {
            if (response.data && _.isPlainObject(response.data)) {
                resolve(Object.assign(API, response.data))
            }else{
                resolve(API)
            }
        }, () => {
            resolve(API)
        });
    })
}
export default API;


